#ifndef COM_H
#define COM_H

#include "porting_mspm0g3507.h"

#define CAM_DATA_IN 0x00;
#define CAM_DATA_OUT 0x01;

#define CAM_FRAME_HEAD1     0xAA
#define HC05_FRAME_HEAD1    0xAB

typedef struct
{
    uint8_t rx_byte;
    uint8_t rx_buffer[5];
    uint8_t rx_buffer_backup[5];
    uint8_t rx_index;
    uint32_t rx_ok_cnt;
    struct{
        uint8_t func;
        uint8_t data;
    }data;
}hc05_t;

typedef struct
{
    uint8_t rx_byte;
    uint8_t rx_buffer[5];
    uint8_t rx_buffer_backup[5];
    uint8_t rx_index;
    uint32_t rx_ok_cnt;
    struct{
        int16_t xerror;
        int16_t yerror;
    }data;
}CamHandle_t;

void com_start(uint8_t mode);
void com_stop(void);
void cam_send(uint8_t flag);
void com_mode(uint8_t mode);
void hc05_recv(hc05_t *self, uint8_t data, uint8_t packet_lengh);
void cam_recv(CamHandle_t *self, uint8_t data, uint8_t packet_lengh);

#endif